#include <cstdio>
#include <cstring>

#define INF 0x3F3F3F3F
#define MAXN 105
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)

int N;
int G[MAXN][MAXN];

int main() {
	while (true) {
		scanf("%d", &N);
		if (N==0) break;
		//Input
		memset(G, 0x3F, sizeof(G));
		for (int i=1; i<=N; i++) {
			int b;
			scanf("%d", &b);
			for (int j=1; j<=b; j++) {
				int v, c;
				scanf("%d%d", &v, &c);
				G[i][v] = c;
			}
		}
		//Floyd
		for (int k=1; k<=N; k++) {
			for (int i=1; i<=N; i++) {
				for (int j=1; j<=N; j++) {
					G[i][j] = MIN(G[i][j], G[i][k]+G[k][j]);
				}
			}
		}
		//Output
		int min = INF;
		int start = 0;
		for (int i=1; i<=N; i++) {
			int max = 0;
			for (int j=1; j<=N; j++) {
				if (i==j) continue;
				max = MAX(max, G[i][j]);
			}
			if (max < min) {
				min = max;
				start = i;
			}
		}
		if (min >= INF) {
			printf("disjoint\n");
		} else {
			printf("%d %d\n", start, min);
		}
	}
	return 0;
}
